﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web.AdminPage
{
    public partial class FrmMessageEdit : WebCommon
    {
        public Model.tb_message model=new Model.tb_message();
        public int mes_type_id = 0;
   
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (!Page.IsPostBack)
            {
                if (Request.QueryString["Id"]!=null)
                {
                    if (Request.QueryString["Id"].Trim().Length > 0)
                    {
                        GetModel(Convert.ToInt32(Request.QueryString["Id"]));
                    }
                }
                
               
            }
        }
        public void GetModel(int Id)
        {
            int serverId = Convert.ToInt32(Common.UICookie.ReadCookie("UId")); 
            Model.tb_message data = Common.SqlExption.GetList<Model.tb_message>().FirstOrDefault(c => c.Id.Equals(Id));
            if (Request.QueryString["mes_type_id"] != null)
                {
                    int tid = 0;
                    if (int.TryParse(Request.QueryString["mes_type_id"].ToString(), out tid))
                    {
                        mes_type_id = tid;
                    }
                }

            if (data!=null)
            {
                model = data;
            }
            else
            {
                model.Id = 0;
                model.create_time = DateTime.Now;
                model.mes_type_id = mes_type_id;
                model.server_id = serverId;
            }

           


        }
    }
}
